/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ComputacaoEvolutiva.java
 *
 * Created on 21/05/2012, 16:15:37
 */

package ui;

import compevol.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.io.File;
import java.io.IOException;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.general.Dataset;
import org.jfree.data.general.DatasetGroup;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.data.xy.DefaultXYDataset;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.util.Rotation;

/**
 *
 * @author vitor
 */
public class ComputacaoEvolutiva extends javax.swing.JFrame {

    /** Creates new form ComputacaoEvolutiva */
    public ComputacaoEvolutiva() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        maxIteracoes = new javax.swing.JTextField();
        populacaoInicial = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        logExecucao = new javax.swing.JTextArea();
        graficoSaida = new javax.swing.JPanel();
        funcaoEscolhida = new javax.swing.JComboBox();
        executar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        probabilidadeMutacao = new javax.swing.JComboBox();
        probabilidadeCruzamento = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        selecao = new javax.swing.JComboBox();
        crossover = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Computação Evolutiva");
        setBounds(new java.awt.Rectangle(100, 100, 400, 400));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setResizable(false);

        maxIteracoes.setText("50");

        populacaoInicial.setText("100");

        logExecucao.setColumns(20);
        logExecucao.setEditable(false);
        logExecucao.setRows(5);
        jScrollPane1.setViewportView(logExecucao);

        graficoSaida.setBackground(new java.awt.Color(255, 255, 255));

        javax.swing.GroupLayout graficoSaidaLayout = new javax.swing.GroupLayout(graficoSaida);
        graficoSaida.setLayout(graficoSaidaLayout);
        graficoSaidaLayout.setHorizontalGroup(
            graficoSaidaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 512, Short.MAX_VALUE)
        );
        graficoSaidaLayout.setVerticalGroup(
            graficoSaidaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 279, Short.MAX_VALUE)
        );

        funcaoEscolhida.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "F2", "F4" }));

        executar.setText("Executar");
        executar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                executarActionPerformed(evt);
            }
        });

        jLabel1.setText("Escolha a função:");

        jLabel2.setText("Número máximo de gerações:");

        jLabel3.setText("População inicial:");

        jLabel4.setText("Gráfico de saída:");

        jLabel5.setText("Resultado da execução:");

        jLabel6.setText("Probabilidade de Cruzamento:");

        jLabel7.setText("Probabilidade de Mutação:");

        probabilidadeMutacao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0.01", "0.02", "0.03", "0.04", "0.05", "0.06", "0.07", "0.08", "0.09", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1" }));
        probabilidadeMutacao.setSelectedIndex(9);

        probabilidadeCruzamento.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0.6", "0.7", "0.8", "0.9", "1" }));

        jLabel8.setText("Tipo de Seleção:");

        jLabel9.setText("Tipo de Crossover:");

        selecao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Roleta", "Torneio" }));

        crossover.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Um ponto", "N pontos" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel4)
                                    .addGap(239, 239, 239)
                                    .addComponent(executar, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE)
                                    .addGap(47, 47, 47))
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel6)
                                        .addComponent(jLabel7)
                                        .addComponent(jLabel1)
                                        .addComponent(jLabel3)
                                        .addComponent(jLabel2))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(funcaoEscolhida, 0, 131, Short.MAX_VALUE)
                                        .addComponent(populacaoInicial)
                                        .addComponent(probabilidadeMutacao, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(probabilidadeCruzamento, 0, 78, Short.MAX_VALUE)
                                        .addComponent(maxIteracoes)
                                        .addComponent(selecao, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(crossover, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                .addComponent(graficoSaida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel8)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 415, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(funcaoEscolhida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel2)
                                    .addComponent(maxIteracoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(12, 12, 12)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel3)
                                    .addComponent(populacaoInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel6)
                                    .addComponent(probabilidadeCruzamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel7)
                                    .addComponent(probabilidadeMutacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel8)
                                    .addComponent(selecao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel9)
                                    .addComponent(crossover, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addComponent(jLabel4))
                            .addComponent(executar))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(graficoSaida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 491, Short.MAX_VALUE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


    /*private JFreeChart createChart(PieDataset dataset, String title) {

        JFreeChart chart = ChartFactory.createPieChart3D(
            title,  				// chart title
            dataset,                // data
            true,                   // include legend
            true,
            false
        );

        PiePlot3D plot = (PiePlot3D) chart.getPlot();
        plot.setStartAngle(290);
        plot.setDirection(Rotation.CLOCKWISE);
        plot.setForegroundAlpha(0.5f);
        return chart;

    }*/

     /**
     * Creates a chart.
     *
     * @param dataset  the data for the chart.
     *
     * @return a chart.
     */
    private JFreeChart createChart(final XYDataset dataset) {

        // create the chart...
        final JFreeChart chart = ChartFactory.createXYLineChart(
            "Melhor fitness",      // chart title
            "Geração",                      // x axis label
            "Fitness",                      // y axis label
            dataset,                  // data
            PlotOrientation.VERTICAL,
            true,                     // include legend
            true,                     // tooltips
            false                     // urls
        );

        // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
        chart.setBackgroundPaint(Color.white);

//        final StandardLegend legend = (StandardLegend) chart.getLegend();
  //      legend.setDisplaySeriesShapes(true);

        // get a reference to the plot for further customisation...
        final XYPlot plot = chart.getXYPlot();
        plot.setBackgroundPaint(Color.lightGray);
    //    plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
        plot.setDomainGridlinePaint(Color.white);
        plot.setRangeGridlinePaint(Color.white);

        final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        //renderer.setSeriesLinesVisible(0, false);
        renderer.setSeriesShapesVisible(0, false);
        plot.setRenderer(renderer);

        // change the auto tick unit selection to integer units only...
        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        //rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        // OPTIONAL CUSTOMISATION COMPLETED.

        return chart;

    }



    private void executarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_executarActionPerformed
        // Criacao da configuracao
        Configuracao config = new Configuracao();

        /* Escolha da funcao */
        switch(funcaoEscolhida.getSelectedIndex())
        {
            case -1:
            case 0:
                config.funcao = new Funcao2();
                config.minValue = -5.12; //para cromossomos, ou dominio da funcao
                config.maxValue = 5.12;
                config.numValores = 3; //valores de x1, x2, x3... para a funcao
                break;
            case 1:
                config.funcao = new Funcao4();
                config.minValue = -100; //para cromossomos, ou dominio da funcao
                config.maxValue = 100;
                config.numValores = 10; //valores de x1, x2, x3... para a funcao
                break;
        }

        /* Escolha do tipo de selecao */
        switch(selecao.getSelectedIndex())
        {
            case -1:
            case 0:
                config.selecao =  new SelecaoRoleta();
                break;
            case 1:
                config.selecao =  new SelecaoTorneio();
                break;
        }
        
        /* Escolha do tipo de crossover */
        switch(crossover.getSelectedIndex())
        {
            case -1:
            case 0:
                config.crossover = new CrossoverUmPonto();
                break;
            case 1:
                config.crossover = new CrossOverMultiPonto();
                break;
        }

        /* Escolha do numero de geracoes */
        //config.maxIteracoes = 50;
        config.maxIteracoes = Math.abs(Integer.parseInt(maxIteracoes.getText()));


        /* Escolha do tamanho da populacao inicial */
        //config.populacaoInicial = 100;
        config.populacaoInicial = Math.abs(Integer.parseInt(populacaoInicial.getText()));

        /* Escolha da probabilidade de cruzamento */
        //config.probabilidadeCruzamento = 0.9;
        config.probabilidadeCruzamento = Double.parseDouble(probabilidadeCruzamento.getSelectedItem().toString());

        /* Escolha da probabilidade de mutacao */
        //config.probabilidadeMutacao = 0.05;
        config.probabilidadeMutacao = Double.parseDouble(probabilidadeMutacao.getSelectedItem().toString());

        // Limiar de erro utilizado
        config.pararSeErroSolucaoMenorQue = 0;

        // Instancia o gerenciador de populacao com as configurações
        Populacao geracao = new Populacao(config);
        geracao.geraPopInicial();

        // Limpa os resultados anteriores
        logExecucao.setText("");

        // Informa os dados incluidos para essa execucao
        logExecucao.append("CONFIGURAÇÃO ESCOLHIDA:\n");
        logExecucao.append("\n\tFunção: "+config.funcao.toString());
        logExecucao.append("\n\tGerações: "+config.maxIteracoes);
        logExecucao.append("\n\tPopulação: "+config.populacaoInicial);
        logExecucao.append("\n\tProb. Cruzamento: "+config.probabilidadeCruzamento);
        logExecucao.append("\n\tProb. Mutação: "+config.probabilidadeMutacao);
        logExecucao.append("\n\tSeleção: "+config.selecao.toString());
        logExecucao.append("\n\tCrossover: "+config.crossover.toString());
        logExecucao.append("\n\n");

        // Itera ate que tenha criterio de parada
        logExecucao.append("MELHORES INDIVÍDUOS:\n");
        logExecucao.append("\n\tGeracao Inicial: " + geracao.melhorIndividuo());
        int ger = 1;

        //usado no grafico:
        XYSeries serieFitnessMaximo = new XYSeries("fitness");


        while (!geracao.criterioDeParada()) {
            geracao.novaGeracao();

             Individuo melhor = geracao.melhorIndividuo();

             //serieFitnessMaximo.add(1.0, melhor);
             double melhorValor = melhor.avalia();
             serieFitnessMaximo.add(ger,melhorValor );
             

            logExecucao.append("\n\tGeracao ("+ger+"): " + melhorValor);
            ger++;
        }

        logExecucao.append("\n\n\t----- Fim da execução -----\n");

        Individuo melhor =  geracao.melhorIndividuo();

        logExecucao.append("\nFitness do melhor individuo: "+ melhor );
        for(int i = 0; i < melhor.cromossomos.size(); i++)
            logExecucao.append("\n\tGene ("+(i+1)+"): "+ melhor.valores()[i]);



         //Criando o dataset de fitness máximo
        //PieDataset dataset = createDataset();



        //org.jfree.data.general.ValueDataset;

        /*DefaultPieDataset result = new DefaultPieDataset();
        result.setValue("Linux", 29);
        result.setValue("Mac", 20);
        result.setValue("Windows", 51);



        
        PieDataset dataset =  result;
*/

        //
        

        XYSeriesCollection dataset =  new XYSeriesCollection(); //(XYSeriesCollection) createDataset();
        dataset.addSeries(serieFitnessMaximo);



        //Criando o cráfico a partir dos dados de fitness maximo
        //JFreeChart chart = createChart(dataset, "Fitness méximo");
        final JFreeChart chart = createChart(dataset);
        //JFreeChart chart = createChart(
        //coloca o grafico dentro de um panel
        ChartPanel chartPanel = new ChartPanel(chart);
        
        graficoSaida.setLayout(new java.awt.BorderLayout());//precisa disso, senão não funciona. porque? Nem idéia...
        graficoSaida.removeAll();
        graficoSaida.add(chartPanel); 

        graficoSaida.validate();


        //chartPanel
        // default size
        //chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        // add it to our application
        //setContentPane(chartPanel);
        //graficoSaida.setContentPane(chartPanel);
        //graficoSaida.set

        //chartPanel.setCon

        //graficoSaida.getRootPane().setContentPane(chartPanel);

        //chartPanel.setc


/*Incluindo o grafico de teste*/
        // This will create the dataset 
        //PieDataset dataset = createDataset();
        //GeradorGrafico gg = new GeradorGrafico(dataset,"Titulo do grafico");
        // based on the dataset we create the chart
//        JFreeChart chart = createChart(dataset, "Titulo do grafico");
        // we put the chart into a panel
        //ChartPanel chartPanel = new ChartPanel(gg.getChart());
        // default size
//        chartPanel.setPreferredSize(new java.awt.Dimension(graficoSaida.getWidth(), graficoSaida.getHeight()));
        // add it to our application
//        setContentPane(chartPanel);
//        graficoSaida = chartPanel;
//        graficoSaida.setBackground(Color.red);
//        getContentPane().add(graficoSaida); 
        //this.graficoSaida.add(chartPanel);
//        chartPanel.setVisible(true);
//        graficoSaida.setVisible(true);
//        graficoSaida.setLocation(0, 0);
//        graficoSaida.add(chartPanel);
//        graficoSaida.repaint();
//        logExecucao.append(chartPanel.getComponents().toString());

/*Incluindo o grafico de teste*/
    }//GEN-LAST:event_executarActionPerformed
/*teste*/
    /*private  PieDataset createDataset() {
        DefaultPieDataset result = new DefaultPieDataset();
        result.setValue("Linux", 29);
        result.setValue("Mac", 20);
        result.setValue("Windows", 51);
        return result;
        
    */
/** * Creates a chart */

//    private JFreeChart createChart(PieDataset dataset, String title) {
//        
//        JFreeChart chart = ChartFactory.createPieChart3D(
//            title,  				// chart title
//            dataset,                // data
//            true,                   // include legend
//            true,
//            false
//        );
//
//        PiePlot3D plot = (PiePlot3D) chart.getPlot();
//        plot.setStartAngle(290);
//        plot.setForegroundAlpha(0.5f);
//        // Salva uma copia do grafico localmente
//        //saveChart(chart);
//        return chart;
//        
//    }

    /**
     * Salva uma copia do grafico localmente, funciona esta sendo
     * usado pra verificar a saida.
     */
//    public void saveChart(JFreeChart chart)
//    {
//        String fileName="C:/Users/user/Downloads/pieChart.jpg";
//        try {
//            /**
//             * This utility saves the JFreeChart as a JPEG
//             * First Parameter: FileName
//             * Second Parameter: Chart To Save
//             * Third Parameter: Height Of Picture
//             * Fourth Parameter: Width Of Picture
//             */
//            ChartUtilities.saveChartAsJPEG(new File(fileName), chart, 800, 600);
//        } catch (IOException e) {
//            e.printStackTrace();
//            System.err.println("Problem occurred creating chart.");
//        }
//    }
//    private XYDataset createDataset() {
//        XYDataset result = new DefaultXYDataset();
//        DatasetGroup dg = new DatasetGroup("teste");
//        result.setGroup(dg);
//        result.setValue("Linux", 29);
//        result.setValue("Mac", 20);
//        result.setValue("Windows", 51);
//        return result;
//        
//    }
//    private JFreeChart createChart(String titulo, String rotuloX, String rotuloY, XYDataset dataset, PlotOrientation orientacao, boolean legenda, boolean tooltips, boolean urls) {
//
//        JFreeChart chart = ChartFactory.createScatterPlot(
//                titulo
//                , rotuloX
//                , rotuloY
//                , dataset
//                , orientacao
//                , legenda
//                , tooltips
//                , urls
//        );
//
////        NumberAxis domainAxis = (NumberAxis) chart.getXYPlot().getDomainAxis();
////        domainAxis.setAutoRangeIncludesZero(false);
////        ChartPanel chartPanel = new ChartPanel(chart);
//        //chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
////        chartPanel.setVerticalAxisTrace(true);
////        chartPanel.setHorizontalAxisTrace(true);
//      //  chartPanel.setVerticalZoom(true);
//       // chartPanel.setHorizontalZoom(true);
////        setContentPane(chartPanel);
//        return chart;
//    }
//    private static String probabilidadesCruzamento() {
//        String ret = "";
//        for(double i=0.01; i < 0.1; i+=0.01)
//            ret += i+",";
//        for(double i=0.1; i < 1; i+=0.1)
//            ret += i+",";
//        return ret.substring(0, -1);
//    }
/*teste*/
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                ComputacaoEvolutiva ce = new ComputacaoEvolutiva();
                ce.pack();
                ce.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox crossover;
    private javax.swing.JButton executar;
    private javax.swing.JComboBox funcaoEscolhida;
    private javax.swing.JPanel graficoSaida;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea logExecucao;
    private javax.swing.JTextField maxIteracoes;
    private javax.swing.JTextField populacaoInicial;
    private javax.swing.JComboBox probabilidadeCruzamento;
    private javax.swing.JComboBox probabilidadeMutacao;
    private javax.swing.JComboBox selecao;
    // End of variables declaration//GEN-END:variables

}
